package com.weixin.app;

import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class WeWorkPage {

    private final  AndroidDriver driver;

    public WeWorkPage() throws MalformedURLException {
        DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("displayName","android");
        desiredCapabilities.setCapability("diviceName","emulator-5554");
        desiredCapabilities.setCapability("appPackage","com.tencent.wework");
        desiredCapabilities.setCapability("appActivity",".launch.WwMainActivity");
        desiredCapabilities.setCapability("noReset",true);
        URL url = new URL("http://127.0.0.1:4723/wd/hub");
        this.driver = new AndroidDriver<>(url,desiredCapabilities);
        this.driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

    }

    public ConTactPage ToConTactPage() throws MalformedURLException {
        this.driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.findElement(By.xpath("//*[@text='通讯录']")).click();
        return new ConTactPage(driver);
    }


}
